
var calendar = null;

function selected(cal, date) {
	cal.sel.value = date; // just update the date in the input field.
	cal.callCloseHandler();
}

function closeHandler(cal) {
    cal.hide();                        // hide the calendar
}

function showCalendar(id) {

	var dateformat = showCalendar.arguments[1];

	
    var el = document.getElementById(id);
    if (calendar != null) {
    	calendar.hide();                 // so we hide it first.
    } else {
	    var cal = new Calendar(false, null, selected, closeHandler);
	    cal.weekNumbers = false;
	    calendar = cal;                  // remember it in the global var
			    	
			if(dateformat){
			
				cal.dateFormat = dateformat; 
			
			}
	    
	    
	    cal.setRange(1950, 2100);        // min/max year allowed.
	    cal.create();
    }
    calendar.parseDate(el.value);      // try to parse the text in field
    calendar.sel = el;                 // inform it what input field we use
    calendar.showAtElement(el);        // show the calendar below it

    return false;
}

